<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>

</body>
<script>
	// 先指定函数，再更改的状态。
	// const p = new Promise(function (resolve, reject) {
	// 	const xhr = new XMLHttpRequest();
	// 	xhr.open("get", "1-错误处理.html");
	// 	xhr.send();
	// 	xhr.onload = function () {
	// 		resolve(xhr.response);
	// 	}
	// });
	// p.then(function (res) {
	// 	console.log(res);
	// })
	
	// 后指定函数，先更改状态
	const p = new Promise(function (resolve, reject) {
		const xhr = new XMLHttpRequest();
		xhr.open("get", "1-错误处理.html");
		xhr.send();
		xhr.onload = function () {
			resolve(xhr.response);
		}
	});
	setTimeout(function(){
		p.then(function (res) {
			console.log(res);
		})
	},4000)
	
</script>
</html>